import 'package:flutter/material.dart';

main(){
  runApp(MaterialApp(
    home:Scaffold(
      body: ZhText('你好，世界！',),
    )
  ));
}

//自定义无状态组件
class ZhText extends StatelessWidget{
   String txt;
   double fs;
   Color fc;
int count =0;
   ZhText(this.txt,{super.key, this.fs=14,this.fc=Colors.green});

  @override
  Widget build(BuildContext context) {
   return TextButton(onPressed: (){
     count++;
     print('点击了 $count 次');
   }, child: Text(
        '$txt $count',
        style: TextStyle(fontSize: fs, color: fc),
      ),
    );
  }
  
}